'''
Created on 31/12/2009

@author: emlyn
'''
from google.appengine.ext import db

class FullPage(db.Model):
    pagename = db.StringProperty(multiline=False)
    sitename = db.StringProperty(multiline=False)
    authoremail = db.StringProperty(multiline=False)
    contenttext = db.TextProperty()
    date = db.DateTimeProperty(auto_now_add=True)

    def GetPagesForSiteName(cls, aSiteName):
        return FullPage.GetPagesForSiteNameWithAmountAndOffset(aSiteName, 1000, 0)
    GetPagesForSiteName = classmethod(GetPagesForSiteName)

    def GetPagesForSiteNameWithAmountAndOffset(cls, aSiteName, amount, offset):
        Pages_query = FullPage.all().filter('sitename =', aSiteName)
        retval = Pages_query.fetch(amount, offset)      
        return retval
    GetPagesForSiteNameWithAmountAndOffset = classmethod(GetPagesForSiteNameWithAmountAndOffset)

    def GetPageBySiteNameAndPageName(cls, aSiteName, aPageName):
        retval = None
        Pages_query = FullPage.all().filter('sitename =', aSiteName).filter('pagename =', aPageName)
        Pages = Pages_query.fetch(1)      
        if Pages:
            retval = Pages[0]
        return retval
    GetPageBySiteNameAndPageName = classmethod(GetPageBySiteNameAndPageName)